<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
    <title>尚品汇 我的收藏</title>
    <link rel="icon" href="/img/favicon.ico">

    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <link rel="stylesheet" type="text/css" href="/css/all.css"/>
    <link rel="stylesheet" type="text/css" href="/css/pages-collect.css"/>
    <style>
        .yui3-g {
            display: flex;
            align-items: center; /* 垂直居中对齐 */
        }

        .yui3-u-1-4 {
            flex: 0 0 25%;
            height: 100px; /* 增加每行的高度 */
        }

        .yui3-u-1-8 {
            flex: 0 0 12.5%;
            height: 100px; /* 增加每行的高度 */
        }

        .yui3-u-6-24 {
            flex: 0 0 50%;
            height: 100px; /* 增加每行的高度 */
        }

        .goods-item {
            display: flex;
            align-items: center; /* 垂直对齐 */
        }

        .item-img img {
            width: 50px; /* 设置图片宽度 */
            height: 50px; /* 设置图片高度 */
            margin-right: 10px; /* 图片与文本之间的间距 */
        }

        .item-price {
            display: flex;
            align-items: center; /* 垂直对齐 */
            justify-content: center; /* 水平居中 */
        }

        .item-action {
            display: flex;
            align-items: center; /* 垂直对齐 */
            justify-content: center; /* 水平居中 */
        }

        .goods-list {
            list-style: none; /* 去掉默认的列表样式 */
            padding: 0;
            margin: 0;
        }

        .collect-th {
            font-weight: bold; /* 表头加粗 */
        }

    </style>

    <div th:include="common/head :: head"></div>
</head>

<body>
<!--head-->
<!-- 头部栏位 -->
<!--页面顶部-->
<div th:include="common/header :: header"></div>

<div class="collect py-container">
    <!--All collected goods-->
    <!--All collected goods-->
    <div class="allgoods" id="collectArray">
        <h4>全部收藏<span></span></h4>
        <div class="collect-main">
            <div class="yui3-g collect-th">
                <div class="yui3-u-1-4"><input class="chooseAll" type="checkbox" name="" id="" value=""/> 全部</div>
                <div class="yui3-u-1-4">商品</div>
                <div class="yui3-u-1-8">单价（元）</div>
                <div class="yui3-u-1-8">操作</div>
            </div>
            <div class="collect-item-list">
                <div class="collect-body">
                    <div class="collect-list" v-for="item in data" :key="item.id">
                        <ul class="goods-list yui3-g">
                            <li class="yui3-u-1-24">
                                <input type="checkbox" v-model="item.isChecked" @click=""
                                       name="chk_list"/>
                            </li>
                            <li class="yui3-u-6-24 goods-item">
                                <div class="item-img"><img :src="item.skuDefaultImg"/></div>
                                <div class="item-msg">{{ item.skuName }}</div>
                            </li>
                            <li class="yui3-u-1-8 item-price">{{ item.skuPrice}}</li>
                            <li class="yui3-u-1-8 item-action">
                                <button @click="removeCollect(item.skuId)">移除</button>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>


</div>

<!--页面底部END-->
<div class="clearfix footer">
    <div class="py-container">
        <div class="footlink">
            <div class="clearfix Mod-list">
                <div class="yui3-g">
                    <div class="yui3-u-1-6">
                        <h4>购物指南</h4>
                        <ul class="unstyled">
                            <li>购物流程</li>
                            <li>会员介绍</li>
                            <li>生活旅行/团购</li>
                            <li>常见问题</li>
                            <li>购物指南</li>
                        </ul>
                    </div>
                    <div class="yui3-u-1-6">
                        <h4>配送方式</h4>
                        <ul class="unstyled">
                            <li>上门自提</li>
                            <li>211限时达</li>
                            <li>配送服务查询</li>
                            <li>配送费收取标准</li>
                            <li>海外配送</li>
                        </ul>
                    </div>
                    <div class="yui3-u-1-6">
                        <h4>支付方式</h4>
                        <ul class="unstyled">
                            <li>货到付款</li>
                            <li>在线支付</li>
                            <li>分期付款</li>
                            <li>邮局汇款</li>
                            <li>公司转账</li>
                        </ul>
                    </div>
                    <div class="yui3-u-1-6">
                        <h4>售后服务</h4>
                        <ul class="unstyled">
                            <li>售后政策</li>
                            <li>价格保护</li>
                            <li>退款说明</li>
                            <li>返修/退换货</li>
                            <li>取消订单</li>
                        </ul>
                    </div>
                    <div class="yui3-u-1-6">
                        <h4>特色服务</h4>
                        <ul class="unstyled">
                            <li>夺宝岛</li>
                            <li>DIY装机</li>
                            <li>延保服务</li>
                            <li>尚品汇E卡</li>
                            <li>尚品汇通信</li>
                        </ul>
                    </div>
                    <div class="yui3-u-1-6">
                        <h4>帮助中心</h4>
                        <img src="./img/wx_cz.jpg">
                    </div>
                </div>
            </div>
            <div class="Mod-copyright">
                <ul class="helpLink">
                    <li>关于我们<span class="space"></span></li>
                    <li>联系我们<span class="space"></span></li>
                    <li>关于我们<span class="space"></span></li>
                    <li>商家入驻<span class="space"></span></li>
                    <li>营销中心<span class="space"></span></li>
                    <li>友情链接<span class="space"></span></li>
                    <li>关于我们<span class="space"></span></li>
                    <li>营销中心<span class="space"></span></li>
                    <li>友情链接<span class="space"></span></li>
                    <li>关于我们</li>
                </ul>
                <p>地址：北京市昌平区宏福科技园综合楼6层</p>
                <p>京ICP备19006430号</p>
            </div>
        </div>
    </div>
</div>

<script src="/js/api/cart.js"></script>
<script th:inline="javascript">
    var collect = new Vue({
        el: '#collectArray',

        data: {
            data: {},
            count: 0
        },

        created() {
            this.init()
        },

        methods: {
            init() {
                cart.collectList().then(response => {
                    this.data = response.data.data
                })
            },

            removeCollect(skuId) {
                cart.removeCollect(skuId).then(response => {
                    console.log('刪除成功')
                    //通知index.html页面刷新数据
                    this.init()

                })
            }
        }
    })
</script>

</body>

</html>
